import App from '@/App.vue'

const http = uni.$u.http

// 项目ID
const project_id = App.globalData.project_id

export default {
	/**
	 * 添加订单
	 *  - post请求
	 */
	addOrderAPI: (data) => {
		return http.post('/order', {
			project_id,
			...data
		}, {
			custom: {
				auth: true
			}
		});
	},

	/**
	 * 获取订单列表
	 *  - get请求
	 * {object} data
	 *  - {string} page 当前页数
	 *  - {string} limit 每页多少条数据
	 *  - {string} order_id 订单号 (筛选用)
	 *  - {string} status 订单状态 (-1：已删除，0：已过期，1:已下单，2:已支付，3:已发货, 4:退货中，5:退款中，6:已完成，7：已取消)
	 */
	getOrderListAPI: (data) => {
		return http.get('/order', {
			params: {
				project_id,
				...data
			},
			custom: {
				auth: true
			}
		});
	},

	/**
	 * 删除订单
	 *  - delete请求	
	 */
	deleteOrderAPI: (id) => {
		return http.delete('/order/' + id, {}, {
			custom: {
				auth: true,
				toast: true
			}
		});
	}
}